<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function formatDate(date) {
        var d = new Date(date),
            year = d.getFullYear(),
            month = '' + (d.getMonth() + 1),
            day = '' + d.getDate();

        if (month.length < 2) month = '0' + month;
        if (day.length < 2) day = '0' + day;

        return [year, month, day].join('-');
    }

    var now=new Date();//实例化时间对象
    var nowDate=new Date(now.getFullYear(),now.getMonth(),now.getDate());//获取年月日时间
    var preDateone=new Date(nowDate.getFullYear(),nowDate.getMonth()-1,nowDate.getDate());//近一个月
    var preDatesix=new Date(nowDate.getFullYear(),nowDate.getMonth()-6,nowDate.getDate());//近六个个月
    var preDatethree=new Date(nowDate.getFullYear(),nowDate.getMonth()-3,nowDate.getDate());//近半年月
    var preDatenov=new Date(nowDate.getFullYear(),nowDate.getMonth()-11,nowDate.getDate());//近十个月
    let oneMonth =formatDate(preDateone.getTime())
    let threeMonth =formatDate(preDatethree.getTime())
    let sixMonth =formatDate(preDatesix.getTime())
    let tenMonth =formatDate(preDatenov.getTime())
    alert(oneMonth);
    alert(threeMonth);
    alert(sixMonth);
    alert(tenMonth);
</script>
</body>
</html>